//
//  UITextView+PlaceHolder.m
//  runtime
//
//  Created by eport on 2020/12/13.
//


//https://www.jianshu.com/p/e0d46032b27f

#import "UITextView+PlaceHolder.h"
#import <objc/runtime.h>

@implementation UITextView (PlaceHolder)



-(void)SetPlaceHolderTextColor:(UIColor *)color fontSize:(CGFloat)font textContent:(NSString *)text{
    
    
    UILabel *placeHolderLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
       placeHolderLabel.text = text;
       placeHolderLabel.numberOfLines = 0;
       placeHolderLabel.textColor = color;
    placeHolderLabel.font = [UIFont systemFontOfSize:font];
       [placeHolderLabel sizeToFit];
       
       if (self.text.length == 0) {
           [self addSubview:placeHolderLabel];//这句很重要不要忘了
       }
       
    [self setValue:placeHolderLabel forKey:@"_placeholderLabel"];

    
}


@end
